package cn.xerllent;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.xerllent.common.annotation.AnonymousAccess;
import cn.xerllent.common.utils.SpringContextHolder;


@EnableAsync
@RestController
@EnableTransactionManagement
@SpringBootApplication (exclude = QuartzAutoConfiguration.class) //防止运行两个quartz
public class XerApp {

	public static void main(String[] args) {
		SpringApplication.run(XerApp.class, args);
        System.out.println(
        		"                    .__  .__                 __   \n"+
        		"___  ___ ___________|  | |  |   ____   _____/  |_ \n"+
        		"\\  \\/  // __ \\_  __ \\  | |  | _/ __ \\ /    \\   __\\\n"+
        		" >    <\\  ___/|  | \\/  |_|  |_\\  ___/|   |  \\  |  \n"+
        		"/__/\\_ \\\\___  >__|  |____/____/\\___  >___|  /__|  \n"+
        		"      \\/    \\/                     \\/     \\/      \n"+
                "赛灵通系统管理后端启动成功 \n官网：http://www.xerllent.cn 提供技术支持ﾞ  \n");
    }

    @Bean
    public SpringContextHolder springContextHolder() {
        return new SpringContextHolder();
    }

    @Bean
    public ServletWebServerFactory webServerFactory() {
        TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory();
        fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
        return fa;
    }

    /**
     * 访问首页提示
     * @return /
     */
    @GetMapping("/")
    @AnonymousAccess
    public String index() {
        return "Backend service started successfully";
    }

}
